﻿<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>消息中心</title>
        <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
        <meta content="yes" name="apple-mobile-web-app-capable"/>
        <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
        <meta content="telephone=no" name="format-detection"/>
        <link href="/js/bootstrap/css/style.css" rel="stylesheet" type="text/css"/>
        <script src="/js/jquery/jquery.min.js"></script>
        <script type="text/javascript" src="/js/bootstrap/js/bootstrap.min.js"></script>
        <script src="/js/plugins/jrender/jrender.min.js"></script>
        <script src="/js/plugins/jquery-form/jquery.form.js"></script>
        <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
        <script src="/js/plugins/dialog2/dialog.min.js"></script>
        <script src="../js/plugins/bootstrap-4.1.1-dist/js/tab.js"></script>
        <script>
            $(function () {
                var userStr = sessionStorage.getItem("user");
                var user = JSON.parse(userStr);
                //直接将currentPage写死,那么只会查询到第二页的数据,之前的data数据丢失,所以此处定义一个临时变量存放data的参数
                var dataList=[];
                var dataList1=[];
                var currentPage =1;
                var currentPage1 =1;
                var totalPage=0;
                var totalPage1=0;
                commentQuery();
                //游记的点赞请求方法
                function travelsQuery() {
                    $.get("/users/"+user.id+"/likeMe",{userId:user.id,currentPage:currentPage,pageSize:5},function (data) {
                        $.merge(dataList,data.list)
                        console.log(dataList);
                        $("#likeMe").renderValues({list:dataList},{
                            setHtml:function (item, value) {
                                var html="";
                                html=value+"点赞了游记";
                                $(item).html(html)
                            },
                            setHref:function (item, value) {
                                var href=$(item).data("href");
                                $(item).attr("href",href+value)
                            }
                        })
                        currentPage +=1;
                        totalPage = data.pages;
                    })
                }
                //评论的点赞请求方法
                function commentQuery() {
                    $.get("/users/"+user.id+"/likeMyComment",{userId:user.id,currentPage:currentPage1,pageSize:5},function (data) {
                        $.merge(dataList1,data.list)
                        console.log(dataList1);
                        $("#likeMyComment").renderValues({list:dataList1},{
                            setHtml:function (item, value) {
                                var html="";
                                html=value+"点赞了你的评论";
                                $(item).html(html)
                            },
                            setHref:function (item, value) {
                                var href=$(item).data("href");
                                $(item).attr("href",href+value)
                            }
                        })
                        currentPage1 +=1;
                        totalPage1 = data.pages;
                    })
                }
                travelsQuery();

                $(window).scroll(function () {
                    if($(window).height()+$(window).scrollTop()>=$(document).height()){
                        //console.log($(window).height());console.log($(window).scrollTop());console.log($(document).height());
                        //判断当前页是否小于等于总页数
                        if(currentPage<=totalPage){
                            travelsQuery();
                        }else if(currentPage1<=totalPage1){
                            console.log(1);
                        }
                        else{
                            $(document).dialog({
                                type : 'notice',
                                infoText: '亲.我也是有限度的',
                                autoClose: 2500,
                                position: 'bottom'  // center: 居中; bottom: 底部
                            });
                        }
                    }
                })
            })


        </script>

    </head>
    <body>

        <!--

         * 17素材vip建站专区模块代码
         * 详尽信息请看官网：http://www.17sucai.com/pins/vip
         *
         * Copyright , 温州易站网络科技有限公司版权所有
         *
         * 请尊重原创，未经允许请勿转载。
         * 在保留版权的前提下可应用于个人或商业用途

        -->

        <section class="aui-flexView" id="likeBody">
            <header class="aui-navBar aui-navBar-fixed">
                <a href="javascript:window.history.go(-1);" class="aui-navBar-item">
                    <span><i class="fa fa-chevron-left" ><</i></span>
                </a>
                <div class="aui-center">
                    <span class="aui-center-title">赞我的</span>
                </div>
                <a href="javascript:;" class="aui-navBar-item">
                    <i class="icon icon-more"></i>
                </a>
            </header>
            <section class="aui-scrollView">
                <div class="aui-tab" data-ydui-tab>
                    <ul class="tab-nav">
                        <li class="tab-nav-item tab-active">
                            <a href="javascript:;">赞游记</a>
                        </li>
                        <li class="tab-nav-item">
                            <a href="javascript:;">赞评论</a>
                        </li>
                    </ul>
                    <div class="tab-panel">
                        <div  id="likeMe">
                        <div class="tab-panel-item tab-active" render-loop="list">
                            <a  class="aui-flex b-line" data-href="/travelContent.html?id=" render-fun="setHref" render-key="list.travelId">
                                <div class="aui-look-img">
                                    <img render-src="list.likerheadImgUrl" alt="">
                                    <span class="aui-look-tag"></span>
                                </div>

                                <div class="aui-flex-box">
                                    <h3 id="likerName" render-fun="setHtml" render-key="list.likeName"></h3>
                                    <p render-html="list.travelTitle"></p>
                                </div>
                            </a>

                        </div>
                        </div>
                       <div id="likeMyComment">
                        <div class="tab-panel-item" render-loop="list">
                            <a data-href="strategySunComment.html?id=" render-fun="setHref" render-key="list.strategyCommentId" class="aui-flex b-line">
                                <div class="aui-look-img">
                                    <img render-src="list.likerheadImgUrl">
                                    <span class="aui-look-tag"></span>
                                </div>
                                <div class="aui-flex-box">
                                    <h3  render-fun="setHtml" render-key="list.likeName"></h3>
                                    <p render-html="list.strategyTitle"></p>
                                </div>
                            </a>
                        </div>
                        </div>
                    </div>
                </div>
            </section>
        </section>

    </body>
</html>
